import wx
import sys


class Frame(wx.Frame):
    def __init__(self, parent, id, title):
        print("Frame __init__")
        super().__init__(parent, id, title)


class App(wx.App):

    def __init__(self, redirect=True, filename=None):
        print("APP__init__")
        super().__init__(redirect, filename, useBestVisual=True)

    def OnInit(self):
        print("OnInit")
        self.frame = Frame(parent=None, id=-1, title='Startup')
        self.frame.Show()
        self.SetTopWindow(self.frame)
        sys.stderr.write("A pretend error message\n")
        return True

    def OnExit(self):
        print("OnExit")
        return -1


if __name__ == '__main__':
    app = App(redirect=True, )
    print("before MainLoop")
    app.MainLoop()
    print("after MainLoop")
